# This file contains functions related to products of derivatives of
# theta functions.

# References:
# [1] Some Product Formulas for Theta Functions in One and Two Variables, 
#     by David Grant

from ThetaFunction import thetaDeriv, theta

# Take product of theta function derivatives, with characteristics
# [a+i/n,b+j/n] for all 0 <= i,j < n, and [i,j] NOT in parameter excl.
def derivProd(n, t, a = 0.5, b = 0.5, excl = [(0,0)]):
    res = 1.0
    for i in range(n):
        for j in range(n):
            if (i,j) in excl:
                continue
            res = res * thetaDeriv(a + float(i)/n, b + float(j)/n, 0.0, t)
    return res

# Take product of theta functions, with characteristics [0.5+i/n, 0.5+j/n]
# for all 0 <= i,j < n, and [i,j] NOT equal to [0,0].  Corresponds to
# prod[1/2,1/2](m,tau) on page 230 of Ref [1].
def prod(n,t):
    res = 1.0
    for i in range(n):
        for j in range(n):
            if i == 0 and j == 0:
                continue
            res = res * theta(0.5 + float(i)/n, 0.5 + float(j)/n, 0.0, t)
    return res